(function(){
    String.prototype.allIndexOf = function(string, ignoreCase) {
        if (this === null) {
            return [-1];
        }
        var t = (ignoreCase) ? this.toString().toLowerCase() : Replace_VietNamese(this),
        s = (ignoreCase) ? string.toString().toLowerCase() : Replace_VietNamese(string.toString()),
        i = Replace_VietNamese(this).indexOf(Replace_VietNamese(s)),
        len = this.length,
        n,
        indx = 0,
        result = [];
        if (len === 0 || i === -1) {
            return [i];
        }
        for (n = 0; n <= len; n++) {
            i = t.indexOf(s, indx);
            if (i !== -1) {
                indx = i + 1;
                result.push(i);
            } else {
                return result;
            }
        }
        return result;
    }
    // To mau
    String.prototype.searchStringColor = function(string, ignoreCase) {
        if(string == '' || string == ' '){
            return this;
        }
        var result = this.allIndexOf(string,ignoreCase);
        var len = result.length;
        strlen = string.length, stroutput = '', t = 0;
        if(result[0] == -1){
            stroutput = this;
        }else{
            for (var i = 0; i < len; i++) {
                stroutput += this.substring(t,result[i]) + '<span class = "lblcolor">' + this.substring(result[i],result[i]+strlen) + '</span>';
                t = result[i]+strlen;
            }
            stroutput += this.substring(t,this.length);
        }
        return stroutput;
    }
})();
function Replace_VietNamese(str) {
    str = str.toLowerCase();
    str = str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g, "a");
    str = str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g, "e");
    str = str.replace(/ì|í|ị|ỉ|ĩ/g, "i");
    str = str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g, "o");
    str = str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g, "u");
    str = str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g, "y");
    str = str.replace(/đ/g, "d");
    return str;
}